Add pre-commit and replace redundant CI lint steps#714
Add pre-commit and replace redundant CI lint steps#714tigercosmos wants to merge 1 commit intosolvcon:masterfrom
Conversation
| make checkascii # ASCII character check | ||
| ``` | ||
|
|
||
| ### Pre-commit |
There was a problem hiding this comment.
Let AI use pre-commit before it pushes the code.
59f56fc to
0ab7a60
Compare
91467d7 to
25433d1
Compare
|
@yungyuc Please take a look. Thanks! |
Add .pre-commit-config.yaml with hooks for clang-format, flake8, cinclude, checkascii, and checktws. Replace the redundant CI lint steps (clang_format_check job, cinclude, checkascii, checktws, flake8) with a single pre_commit job using pre-commit/action. Rename tidy_flake8 to clang_tidy since it now only runs clang-tidy and pilot builds. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
25433d1 to
f0bf3ed
Compare
| jobs: | ||
|
|
||
| clang_format_check: | ||
| pre_commit: |
There was a problem hiding this comment.
Use pre-commit for CI to shorten the CI file.
yungyuc
left a comment
There was a problem hiding this comment.
I am not familiar with https://pre-commit.com/ . After skimming through the website, I do not see its benefits to modmesh.
For local hacking, I preferred to have all checks done manually. It is difficult to align the local development environments.
One who wants to run checks before committing can write a script, which looks like what $ pre-commit run --all-files does.
I am converting the PR to draft. We can discuss here.
| @@ -0,0 +1,50 @@ | |||
| # Copyright (c) 2026, An-Chi Liu <phy.tiger@gmail.com> | |||
| # Copyright (c) 2026, An-Chi Liu <phy.tiger@gmail.com> | ||
| # BSD-style license; see COPYING | ||
| # | ||
| # See https://pre-commit.com for more information |
There was a problem hiding this comment.
I am not sure an additional dependency for running the check is good.
|
As far as I know, Although this tool adds some dependencies, these things are optional. The lint and code style we want to check still remain in the CI, so everything would be checked before merging. Therefore, I think it's good because it can make developers do some basic prechecks in local side easier by packaging them under This is the pre-commit docs I have read before from an open-source project called |
|
|
|
Feeling easy or not depends on familiarity. For someone not familiar with a tool, it will not be easy. From my personal perspective, the existing Could you please provide more objective analysis of why pre-commit is good (not necessarily better)? And where it is better than the existing make targets? |
I think current Using |
|
@ExplorerRay pointed out a good feature. |
It is a plus to have an automatic way to manage the dependencies required by the actions. What are the limitations of the actions and action dependencies?
It sounds good to have additional modularity for building/CI. It probably worth of clarification for how it would strengthen or interfere the modularization that we want for the Github Actions. @tigercosmos @chestercheng @ExplorerRay I'd like to have your input on this.
Good point. What I meant by "the only dependency" was for the tool itself, not the jobs it runs. Pre-commit has few dependencies but still more than make has. |
Summary
.pre-commit-config.yamlwith hooks matching CI lint checks:cpp/andgtests/thirdparty/tmp/_deps)pre_commitjob usingpre-commit/actionclang_format_checkjob and individualmake cinclude,make checkascii,make checktws,make flake8steps from CItidy_flake8job toclang_tidy(now only runs clang-tidy + pilot builds)Test plan
pre-commit run --all-filespasses all 5 hooks locallypre_commitjob passesclang_tidyjob passes (unchanged functionality)🤖 Generated with Claude Code